<script setup lang="ts">
import { computed } from 'vue';
import { useUserStore } from '@/store/modules/user.ts';

const props = defineProps<{
  permission: string | string[];
}>();
const { buttons } = useUserStore();

// 是否拥有权限
const hasPermission = computed(() => {
  if (Array.isArray(props.permission)) {
    return props.permission.every(p => buttons?.includes(p));
  } else {
    return buttons?.includes(props.permission);
  }
});
</script>

<template>
  <slot :hasPermission="hasPermission"></slot>
</template>

<style scoped>
/* code... */
</style>
